﻿<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>珠峰社区</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <!-- basic styles -->
  <link href="/css/bootstrap.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="/css/font-awesome.min.css" />
  <link rel="stylesheet" href="/css/community.css" />
  <!--[if lt IE 9]>
  <script src="/js/respond.min.js"></script>
  <![endif]-->
</head>

<body>
<% include ./include/header %>
<div class="main-container" id="main-container">
  <div class="main-container-inner">
    <a class="menu-toggler" id="menu-toggler" href="#"> <span class="menu-text"></span> </a>
    <div class="sidebar" id="sidebar">
      <ul class="nav nav-list">
        <li class="active"> <a href="/category/list/1/10"> <i class="icon-dashboard"></i> <span class="menu-text"> 栏目管理 </span> </a> </li>
        <li> <a href="/article/list/1/10"> <i class="icon-text-width"></i> <span class="menu-text"> 主题管理 </span> </a> </li>
      </ul>
      <!-- /.nav-list -->

      <div class="sidebar-collapse" id="sidebar-collapse">
        <i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
      </div>
    </div>
    <div class="main-content">
      <div class="breadcrumbs" id="breadcrumbs">

        <ul class="breadcrumb">
          <li> <i class="icon-home home-icon"></i> <a href="#">后台管理系统</a> </li>
          <li class="active">栏目管理</li>
        </ul>


        <div class="nav-search" id="nav-search">
          <form class="form-search">
            <span class="input-icon">
            <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
            <i class="icon-search nav-search-icon"></i> </span>
          </form>
        </div>

      </div>

      <div class="page-content" style="width: 100%;">
            <div class="row">
              <div class="col-sm-12 ">
                <div class="widget">

                  <div class="widget-head">
                    <div class="pull-left">Tables</div>
                    <div class="widget-icons pull-right">
                      <a class="btn btn-default" href="/category/add" >新增顶级栏目</a>
                      <a href="#" class="wclose"><i class="icon-remove"></i></a>
                    </div>
                    <div class="clearfix"></div>
                  </div>

                  <div class="widget-content" style="display: block;">

                    <table class="table table-striped table-bordered table-hover ">
                      <thead>
                      <tr>
                        <th>主键</th>
                        <th>栏目名称</th>
                        <th>栏目类型</th>
                        <th>栏目序号</th>
                        <th>父栏目名称</th>
                        <th>操作</th>
                      </tr>
                      </thead>
                      <tbody>


                        <%
                         if(categories && categories.length>0){
                         for(var i=0;i<categories.length;i++){
                            var category = categories[i];
                             %>
                          <tr>
                          <td><%=category._id%></td>
                          <td><%=category.name%></td>
                          <td>
                            <%
                               if(!(category.parent_id)){
                               %>顶级栏目<%}
                                 else if(!(category.children)){
                            %>终极栏目<%}
                              else{
                            %>普通栏目<%}
                            %>
                          </td>
                          <td><%=category.order_by%></td>
                          <td><%
                              if(category.parent_id){
                                %>
                                    <%=category.parent_id.name%>
                                <%
                              }else{
                                %>无<%
                              }
                            %></td>
                          <td>
                         <!--   <a class="btn btn-default"  href="/category/view/<%=category._id%>">查看</a>-->
                            <a class="btn btn-default"  href="/category/edit/<%=category._id%>">修改</a>
                            <a class="btn btn-default"  href="/category/delete/<%=category._id%>">删除</a>
                              <a class="btn btn-default"  href="/category/adder/<%
                              if(category.parent_id){
                              %><%=category.parent_id._id%><%
                              }else{
                              %><%=category._id%><%
                              }
                              %>">新增</a>
                          </td>
                        </tr>
                             <%
                           }
                         }
                        %>
                      </tbody>
                    </table>

                    <div class="widget-foot">


                      <ul class="pagination pull-right">
                        <%
                          var num;
                          if(pageNum%5==0)
                             num = pageNum/5 - 1;
                          else
                             num = Math.floor(pageNum/5);
                        var start = num*5+1;
                        var end = start+4>totalPage?totalPage:start+4;
                        if(start>1){
                          %> <li><a href="/category/list/<%=start-1%>/<%=pageSize%>">Prev</a></li><%
                        }
                         %>
                        <%
                          for(var i=start;i<=end;i++){
                            %>
                              <li><a href="/category/list/<%=i%>/<%=pageSize%>"><%
                                    if(i == pageNum){
                                  %><font color="red"><%=i%></font><%
                                    }else{
                                      %><%=i%><%
                                    }
                                  %></a></li>
                            <%
                          }
                          if(totalPage > end){
                            %><li><a href="/category/list/<%=end+1%>/<%=pageSize%>">Next</a></li><%
                          }
                        %>
                      </ul>
                      <div class="clearfix"></div>
                    </div>

                  </div>

                </div>

              </div>
            </div>

      </div>
        </div>


        </div>

      </div>


    </div>

    

  </div>



  <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse"> <i class="icon-double-angle-up icon-only bigger-110"></i> </a> </div>


<script src="/js/jquery-2.0.3.min.js"></script>

<script src="/js/bootstrap.min.js"></script>
<script src="/js/ace.js"></script>


</body>
</html>
